package cn.lingyangwl.agile.model.module.perm;

import com.alibaba.ttl.TransmittableThreadLocal;

/**
 * 请求ttl
 * ttl: TransmittableThreadLocal
 * @author shenguangyang
 */
public class DataRuleContextHolder {
    private static final TransmittableThreadLocal<DataRuleContext> ttl = new TransmittableThreadLocal<>();

    public static DataRuleContext get() {
        DataRuleContext context = ttl.get();
        if (context == null) {
            synchronized (DataRuleContextHolder.class) {
                context = new DataRuleContext();
                set(context);
            }
        }
        return context;
    }

    public static void set(DataRuleContext context) {
        ttl.set(context);
    }

}
